package lab14;

public class task3 {

	public static void main(String[] args) {
		int i;
		char [] correct = {'T','T','F','F','T'};
		char [][] students = {{'T',	'F',	'T',	'T',	'T'},
							{'T',	'T',	'T',	'T',	'T'},
							{'T',	'T',	'F',	'F',	'T'},
							{'F',	'T',	'F',	'F',	'F'},
							{'F',	'F',	'F',	'F',	'F'},
							{'F',	'T',	'T',	'T',	'F'}};


		System.out.println("Enter the answers of the students in a 6 * 5 2D-array:");

		int [] grades = getGrades(correct,students);
		
		System.out.println("#Student\tGrade out of 25");
		
		for(i = 0 ; i<6 ; i++) {
				System.out.printf("%7d\t%14d\n",i+1,grades[i]*5);
			}

	}


	private static int[] getGrades(char[] correct , char [][] students) {

		int i , j;
		int [] grades = { 0 , 0 , 0 , 0 , 0 , 0};

		for(i = 0 ; i < 6 ; i++) {
			for(j = 0 ; j < 5 ; j++) {
				if(students[i][j] == correct[j]){
					grades[i]++;
				}					
			}
		}
		return grades;
	}

}
